package MiddlePane;

import javax.swing.*;

/**
 * Creat with IntelliJ IDEA
 * Description:单选题界面
 * Date:2021-12-14
 * Time:11:10
 */
public class Single_choice extends QuestionSetting{
    Box questionSetting = Box.createVerticalBox();//中间盒式布局

    public Single_choice(String ques,String a,String b,String c,String d){
        Box subject = Box.createHorizontalBox();
        JLabel label = new JLabel("单选题：");
        subject.add(label);
        JTextArea q = new JTextArea(ques);//设置题目
        q.setSize(50,3);
        q.setBackground(null);
        q.setLineWrap(true);//设置自动换行
        q.setWrapStyleWord(true);//设置以单词为界换行
        q.setEditable(false);//设置不可编辑
        subject.add(q);
        questionSetting.add(subject);

        Box choice = Box.createVerticalBox();
        JRadioButton c1 = new JRadioButton(a);
        JRadioButton c2 = new JRadioButton(b);
        JRadioButton c3 = new JRadioButton(c);
        JRadioButton c4 = new JRadioButton(d);

        //创建一个按钮组 - 同时只能选其中一个选项
        ButtonGroup group = new ButtonGroup();
        group.add(c1);
        group.add(c2);
        group.add(c3);
        group.add(c4);


        choice.add(c1);
        choice.add(c2);
        choice.add(c3);
        choice.add(c4);

        JButton submit = new JButton("确定");//提交按钮
        submit.addActionListener(listener);
        choice.add(submit);

        questionSetting.add(choice);

    }

    public Box getquestionSetting() {
        return questionSetting;
    }

}
